<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- <div myattr="hello">我是div</div> -->

    <ul>
        <li>11</li>
        <li>22</li>
        <li>33</li>
    </ul>
    <script>
        document.querySelectorAll("li").forEach(function(item,key){
            item.onclick = function(){
                console.log(key)
            }
        })


        // var ele = document.querySelector("div");
        // // myattr 是 元素的属性
        // ele.myattr="123";
        // // ele.setAttribute
        // console.dir(ele);


    </script>
</body>
</html>